<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>首页</title>
<%@ include file="/pages/inc/taglibs.jsp"%>
<%@ include file="/pages/inc/header.jsp"%>
<%@ include file="/pages/inc/common.jsp"%>
</head>
<body>
<div class="container-fluid">
    <div class="barTitle">
        <span>项目设备费用</span>
    </div>
<table id="projectDeviceListGrid"></table>
<div id="projectDeviceListGrid_prowed"></div>
</div>
<script type="text/javascript">
	/*
	加载服务器端响应的数据
	*/
	var projectDeviceListGrid = new biz.grid({
		id:"#projectDeviceListGrid",
		url: "<c:url value='/deduction/device/list' />",/*必需，grid初始化时请求数据的远程url*/
		datatype: "json",/*必需，请求服务器端数据时，数据类型需设为json*/
		editurl:"<c:url value='/deduction/device/edit' />" ,/*新增、编辑、删除数据时提交到的url*/
		postData:{"projectId":$("#projectId").val()},
		colModel:[
		    {name:'id',index:'id', label:"id",width:75,sortable:false,key:true,hidden:true},
		    {name:'deviceName',index:'deviceName',label:"设备名称", width:100,editable:true,editoptions:{readonly:false},formoptions:{ rowpos:1, colpos:1}},
		    {name:'startDate',index:'startDate',label:"使用开始时间", width:50, align:"right",editrules:{required:true},editable:true,formoptions:{ rowpos:7, colpos:1}},
		    {name:'endDate',index:'endDate',label:"使用结束日期", width:50, align:"right",editrules:{required:true},editable:true,formoptions:{ rowpos:8, colpos:1}},
		    {name:'memo',index:'memo',label:"备注", width:200, align:"right",editrules:{required:true},editable:true,formoptions:{ rowpos:8, colpos:1}}
		],
		navtype:"top",
		navopt:{view:true,edit:true,add:true,del:false}/*导航栏属性设置：哪些按钮显示*/,
		pager: '#projectDeviceListGrid_prowed',
		
		}).navButtonAdd('#projectDeviceListGrid_toppager',{ //增加按钮api
		    caption:"删除", // 按钮名
		    buttonicon:"ui-icon-trash", //按钮图标
		    position:"last",
		    onClickButton: function(){ //按钮单击事件
		    	new biz.alert({type:"confirm",message:"确定要删除？",title:"删除确认"
		    		,callback:function(result){
			    		if (!result) {
			    			return;
			    		}
			    		var json = {};
			    		var condition = ""
			    		var rowids = projectListGrid.getGridParam('selarrrow');
			    		if(rowids.length==0){
			    			showInfo("请选择要删除的记录！");
			    			return;
			    		}else{
			    			condition = rowids.join(",");
				    	}
			    		json.ids = condition;
						$.ajax({
							type : "POST",
							url: "<c:url value='/company/project/delete'/>",
							cache:false,
							dataType : "json",
							data : json, 
							success: function(data){
								projectListGrid.trigger('reloadGrid');
							},
							error:function(data){
								alert("error");
							}
						});
					}
				});
		    }
		});
</script>
</body>
</html>